package com.corpgovernment.organization.dataloader.db;

import com.corpgovernment.api.hotel.product.soa.HotelProductClient;
import com.corpgovernment.api.hotel.product.vo.CheckHotelOrderAmountRequest;
import com.corpgovernment.api.hotel.product.vo.QueryHotelOrderDetailResponseVo;
import com.corpgovernment.common.base.JSONResult;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.Optional;

@Slf4j
@Component
public class HotelOrderClientLoader {
    @Autowired
    private HotelProductClient hotelProductClient;


    public Map<Long, List<QueryHotelOrderDetailResponseVo>> getHotelOrderAmount(CheckHotelOrderAmountRequest request) {

        JSONResult<Map<Long, List<QueryHotelOrderDetailResponseVo>>> result = hotelProductClient.getHotelOrderAmount(request);
        if (result == null || result.getData() == null) {
            log.warn("查询支付单数据异常:" + Optional.ofNullable(result).map(JSONResult::getMsg).orElse("接口无响应"));
            return Maps.newHashMap();
        }
        return result.getData();
    }
}
